#include <stdio.h>
#include <windows.h>
#define MAX 10

void sort(int *address);
void exchange(int *a, int *b);

int main()
{
    int data[MAX] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
    int i = 0;
    sort(&data[0]);
    for (i = 0; i < 10; i++)
    {
        printf("%4d", data[i]);
    }
    printf("\n");
    system("pause");
}

void exchange(int *a, int *b)
{
    int c;
    c = *a;
    *a = *b;
    *b = c;
}

void sort(int *pdata)
{
    int i = 0;
    int j = 0;
    for (i = 0; i < MAX; i++)
    {
        printf("data[%d]=%d\n", i, *(pdata + i));
    }
    for (i = MAX; i >= 0; i--)
    {
        for (j = 0; j < i - 1; j++)
        {
            if (*(pdata + j) > *(pdata + j + 1))
            {
                exchange((pdata + j), (pdata + j + 1));
            }
        }
    }
}